* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
    overflow-x: hidden;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 10px 20px;
    width: 100%;
}

header {
    text-align: center;
    margin-bottom: 20px;
}

h1 {
    color: white;
    font-size: 2.2rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.top-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60px;
}

.auth-section {
    display: flex;
    justify-content: center;
    gap: 15px;
}

.auth-form {
    background: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    width: 300px;
}

.auth-form.compact {
    padding: 15px 20px;
    width: auto;
    min-width: 250px;
    max-width: 350px;
}

.auth-form.compact h3 {
    margin-bottom: 10px;
    font-size: 1.1rem;
}

.auth-form.compact input {
    padding: 8px;
    margin-bottom: 10px;
    font-size: 14px;
}

.auth-form.compact button {
    padding: 8px 15px;
    font-size: 14px;
}

.auth-form.compact p {
    margin-top: 8px;
    font-size: 12px;
}

.auth-form h3 {
    margin-bottom: 20px;
    color: #667eea;
    text-align: center;
}

.auth-form input {
    width: 100%;
    padding: 10px;
    margin-bottom: 15px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 16px;
}

.auth-form button {
    width: 100%;
    padding: 12px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.3s;
}

.auth-form button:hover {
    background: #5a6fd8;
}

.auth-form p {
    text-align: center;
    margin-top: 15px;
    font-size: 14px;
}

.auth-form a {
    color: #667eea;
    text-decoration: none;
}

.auth-form a:hover {
    text-decoration: underline;
}

.user-info {
    background: white;
    padding: 15px 30px;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}

.user-info.compact {
    padding: 10px 20px;
    gap: 15px;
    font-size: 14px;
}

.user-info.compact button {
    padding: 6px 12px;
    font-size: 12px;
}

.user-info span {
    color: #667eea;
    font-weight: bold;
}

.user-info button {
    padding: 8px 16px;
    background: #ff6b6b;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.3s;
}

.user-info button:hover {
    background: #ff5252;
}

main {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 20px;
    align-items: start;
    max-width: 1000px;
    margin: 0 auto;
}

.game-section {
    width: 100%;
}

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
    height: fit-content;
    position: sticky;
    top: 20px;
}

.game-container {
    background: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 3px 5px rgba(0,0,0,0.1);
    text-align: center;
    width: 100%;
}

.sidebar .auth-form {
    margin-bottom: 0;
    width: 100%;
    padding: 15px;
}

.sidebar .user-info {
    margin-bottom: 0;
    width: 100%;
    flex-direction: column;
    text-align: center;
    gap: 8px;
    padding: 15px;
}

.sidebar .leaderboard {
    padding: 15px;
    margin-top: 0;
}

.game-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 10px;
}

.score-display h3 {
    color: #667eea;
    margin-bottom: 5px;
}

.controls {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.controls button {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
}

#startBtn {
    background: #4CAF50;
    color: white;
}

#startBtn:hover:not(:disabled) {
    background: #45a049;
}

#pauseBtn {
    background: #ff9800;
    color: white;
}

#pauseBtn:hover:not(:disabled) {
    background: #e68900;
}

#resetBtn {
    background: #f44336;
    color: white;
}

#resetBtn:hover:not(:disabled) {
    background: #da190b;
}

.controls button:disabled {
    background: #cccccc;
    cursor: not-allowed;
    opacity: 0.6;
}

#gameCanvas {
    border: 2px solid #667eea;
    border-radius: 5px;
    background: #f9f9f9;
    margin: 10px 0;
    width: 100%;
    max-width: 400px;
    height: auto;
    aspect-ratio: 1;
}

.game-status {
    margin-top: 20px;
}

.game-status p {
    color: #666;
    font-size: 16px;
}

.leaderboard {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    height: fit-content;
}

.leaderboard h3 {
    color: #667eea;
    margin-bottom: 15px;
    text-align: center;
    font-size: 1.2rem;
}

.leaderboard-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #eee;
}

.leaderboard-item:last-child {
    border-bottom: none;
}

.leaderboard-rank {
    font-weight: bold;
    color: #667eea;
    margin-right: 10px;
}

.leaderboard-name {
    flex: 1;
    color: #333;
}

.leaderboard-score {
    font-weight: bold;
    color: #4CAF50;
}

.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: white;
    padding: 40px;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    max-width: 400px;
    width: 90%;
}

.modal-content h2 {
    color: #667eea;
    margin-bottom: 20px;
}

.modal-content p {
    margin-bottom: 15px;
    font-size: 18px;
    color: #333;
}

.modal-content button {
    padding: 12px 30px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.3s;
}

.modal-content button:hover {
    background: #5a6fd8;
}

@media (max-width: 1200px) {
    main {
        grid-template-columns: 1fr 300px;
        gap: 20px;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 5px 10px;
    }
    
    h1 {
        font-size: 1.8rem;
        margin-bottom: 5px;
    }
    
    .game-container {
        padding: 10px;
    }
    
    #gameCanvas {
        max-width: 100%;
        margin: 10px 0;
    }
    
    .sidebar {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 2px 5px;
    }
    
    .game-container {
        padding: 8px;
    }
    
    #gameCanvas {
        max-width: 95%;
        margin: 5px 0;
    }
    
    .sidebar .auth-form,
    .sidebar .user-info,
    .sidebar .leaderboard {
        padding: 15px;
    }
}

@media (max-width: 1024px) {
    main {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .sidebar {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 20px;
        position: static;
    }
    
    .sidebar .auth-form,
    .sidebar .user-info {
        margin-bottom: 0;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 8px;
    }
    
    h1 {
        font-size: 1.6rem;
        margin-bottom: 5px;
    }
    
    .game-container {
        padding: 10px;
    }
    
    .sidebar {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .game-info {
        flex-direction: column;
        text-align: center;
        gap: 10px;
    }
    
    .controls {
        justify-content: center;
    }
    
    #gameCanvas {
        max-width: 350px;
        margin: 10px 0;
    }
}

@media (max-width: 480px) {
    .auth-form.compact {
        min-width: 180px;
        padding: 8px 12px;
    }
    
    .auth-form.compact h3 {
        font-size: 1rem;
        margin-bottom: 8px;
    }
    
    .auth-form.compact input {
        padding: 6px;
        font-size: 12px;
    }
    
    .auth-form.compact button {
        padding: 6px 12px;
        font-size: 12px;
    }
    
    .user-info.compact {
        padding: 8px 12px;
        font-size: 12px;
        gap: 10px;
    }
    
    .user-info.compact button {
        padding: 4px 8px;
        font-size: 11px;
    }
    
    .container {
        padding: 5px;
    }
    
    .game-container {
        padding: 8px;
    }
    
    h1 {
        font-size: 1.4rem;
        margin-bottom: 5px;
    }
    
    #gameCanvas {
        max-width: 280px;
        margin: 5px 0;
    }
}